package com.algorithm;

/**
 * @Author: 胡成
 * @Version: 0.0.1V
 * @Date: 2018/11/26
 * @Description: 公鸡5元一只，母鸡3元一只，小鸡1元三只，问100元怎样可以买100鸡？
 * 公鸡最多能买20只，母鸡最多能买33只，小鸡最多能买100只
 **/
public class 百钱买百鸡 {

    public static void main(String[] args) {
        execute();
    }

    public static void execute() {
        int cock, hen, chick;
        for (cock = 0; cock <= 19; cock++) {
            for (hen = 0; hen <= 32; hen++) {
                chick = 100 - cock - hen;
                int p = chick % 3;
                if (chick / 3 + cock * 5 + hen * 3 == 100 && p == 0) {
                    System.out.print("公鸡可买：" + cock + "只，");
                    System.out.print("母鸡可买：" + hen + "只，");
                    System.out.println("小鸡可买：" + chick + "只");
                }
            }
        }
    }

}
